home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_1.3 / Read-Me1.3 / Workbench1.3 / Ieee.Examples / Div0 / trapasm.asm < prev    next >
Encoding:
Assembly Source File  |  1988-02-11  |  985 b   |  40 lines

  1.  
  2.     include    'exec/types.i'
  3.     include    'exec/tasks.i'
  4.  
  5.     xref    _localf
  6.     xref    _oldtraphandler
  7.  
  8. *    localf is a table of user trap handlers
  9.  
  10.     xdef    _trapintercept
  11. _trapintercept:
  12. *    called from exec with the following on the stack
  13. *    (sp).w    = trap#        8
  14. *    (sp).w  = 0
  15. *    (sp).w  = sr        12
  16. *    (sp).l  = pc        14
  17. *    other processor dependant gunk
  18. *    We are in supervisor mode
  19. *    all we want to do is check to see if this trap is one
  20. *    we want to handle, if so, rte to correct handler
  21. *    else let other trap handler deal with it.
  22.     movem.l    d0/a0,-(sp)    ; need a data register
  23. *    4(sp) -> ap
  24.     move.l    8(sp),d0    ; get trap number
  25.     asl.l    #2,d0        ; convert in array index
  26.     lea    _localf,a0
  27.     move.l    0(a0,d0.l),d0    ; get alternate usermode vector
  28.     if <>
  29.         move.l    d0,14(sp)    ; modify rte address
  30.         movem.l    (sp)+,d0/a0    ; restore d0/a0, why?
  31.         addq.l    #4,sp        ; remove trap #
  32.         rte            ; close eyes, plug ears
  33.     endif
  34. *    take original trap
  35.     movem.l    (sp)+,d0/a0    ;restore d0 contents
  36.     move.l    _oldtraphandler,-(sp)
  37.     rts            ; jump to it
  38.  
  39.     end
  40.